/*
 * This class creates a colorscale for nodes
 * Writend by Wenyi An
 * 15/06/2013
 * */
package prefuse.demos;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JComponent;
import javax.swing.JLabel;

public class ColorScaleComponent extends JComponent {
	private int red;
	private int green;
	private int blue;
	private int x;
	private String type;

	public ColorScaleComponent(int r, int g, int b, int xx, String t) {
		red = r;
		green = g;
		blue = b;
		x = xx;
		type = t;
	}

	@Override
	public void paint(Graphics g) {

		Color Pigment;
		
		while (x < 255) {
			Pigment = new Color(red, green, blue);
			g.setColor(Pigment);
			g.drawLine(x, 0, x, 50);
			if(type.equals("RED")){
				green = green - 1;
				blue = blue - 1;
			}
			else if(type.equals("GREEN")){
				red = red - 1;
				blue = blue - 1;
			}
			
			x = x + 1;
		}

	}
}